package com.zwz.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zwz.bean.ShiroUser;
import com.zwz.bean.SysResourceBean;
import com.zwz.model.SysResource;
import com.zwz.service.baseConfig.SysResourceService;

/**
 * 首页
 * @author zhangwanzhong
 * 2015年12月29日 下午1:40:14
 */
@Controller
@RequestMapping("/index")
public class IndexController {
	@Autowired
	private SysResourceService sysResourceService;
	
	@RequestMapping(value="/all")
	public Object getTree(HttpServletRequest request)throws Exception{
		Subject user = SecurityUtils.getSubject();
		ShiroUser shiroUser = (ShiroUser)user.getPrincipal();
		SysResourceBean sysResource=new SysResourceBean();
		sysResource.setResource_type("0");
		sysResource.setRole_id(shiroUser.getRoleId());
		sysResource.setTag("0");
		sysResource.setRows(100000);
		List<SysResource> sysResourceList = sysResourceService.findAllResourceByRole(sysResource);
		request.setAttribute("menuList", sysResourceList);
		return "index";
	}
}
